package com.example.csdn.mapper;

import com.example.csdn.DTO.ArticleAddDTO;
import com.example.csdn.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleMapper {

    List<Article> articleList(Integer categoryId, String state, Integer userId);

    @Insert("insert into article(title,content,create_time,state,user_id,category_id,cover_img)" +
            "values (#{title},#{content},now(),#{state},#{userId},#{categoryId},#{coverImg})")
    void add(ArticleAddDTO articleAddDTO);

    @Delete("delete from article where id = #{id}")
    void delete(Integer id);

    @Update("update article set title = #{title}, content = #{content}, state = #{state}, category_id = #{categoryId}, cover_img = #{coverImg} where id = #{id}")
    void update(Article article);

    @Select("select * from article where id = #{id}")
    Article getArticleById(Integer id);
}
